
from flask import Blueprint
from main import siwa
from service.blog_service import BlogServer
from utils.resp_util import RespUtil

bp = Blueprint('blog_blue', __name__)


@bp.get(rule='/blog')
@siwa.doc(tags=["blog"], group="blog")
def blogList():
    return RespUtil.respJson(BlogServer.getBlogs())


@bp.get(rule='/blog/details')
@siwa.doc(tags=["blog"], group="blog")
def details():
    return RespUtil.respJson(BlogServer.getBlogDetails())


@bp.delete(rule='/blog')
@siwa.doc(tags=["blog"], group="blog")
def delete():
    return RespUtil.respJson(BlogServer.deleteBlog())


@bp.put(rule='/blog')
@siwa.doc(tags=["blog"], group="blog")
def update():
    return RespUtil.respJson(BlogServer.editBlog())


@bp.post(rule='/blog')
@siwa.doc(tags=["blog"], group="blog")
def add():
    return RespUtil.respJson(BlogServer.editBlog())
